package com.zj.leetcode.medium.binarySearch;

/**
 * @program: algorithm
 * @description: 丑数 II
 * 264 ugly-number-ii
 * @author: Zhang Bo
 * @create: 2022-01-14 17:05
 **/
public class UglyNumberIi {
    public static void main(String[] args) {
        int n = 10;
        Solution solution = new UglyNumberIi().new Solution();
        System.out.println(solution.nthUglyNumber(n));
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public int nthUglyNumber(int n) {

            if (n == 1) {
                return 1;
            }
            int num = 2;
            int count = 1;
            while (count < n) {
                if (num % 2 == 0 || num % 3 == 0 || num % 5 == 0) {
                    count++;
                }
                num++;
            }

            return num - 1;
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}
